package com.ztf0337.mycurriculumdesign.Utils;

import android.os.Handler;
import android.os.Looper;


public class RefreshMyParkingSpace {
    private final Handler handler = new Handler(Looper.getMainLooper());
    private final Runnable runnable;

    public RefreshMyParkingSpace(Runnable task) {
        this.runnable = new Runnable() {
            @Override
            public void run() {
                task.run(); // 执行传入的任务
                handler.postDelayed(this, 6 * 60 * 1000); // 每6分钟重复
            }
        };
    }

    public void startRepeatingTask() {
        handler.post(runnable);
    }

    public void stopRepeatingTask() {
        handler.removeCallbacks(runnable);
    }
}

